#pragma once

namespace Tmpl {

class Entity;
class EntityProjectile
{
public:
	Entity* GetOwner(){return mOwner;}
	Vec2f GetPos() const { return mPos; }
	Vec2f GetFacing() const { return mFacing; }
	float GetSpeed() const { return mSpeed; }
	float GetDamage() const { return mDamage; }
	float GetAreaOfEffect() const { return mAreaOfEffect; }
	float GetFlightTime() const { return mFlightTime; }

	int GetTarget() const { return mTarget; }
	void SetTarget(int target){mTarget = target; }

private:
	friend class EntityProjectileSystem;

	Entity* mOwner;
	int mTarget;

	Vec2f mPos;
	Vec2f mFacing;
	float mSpeed;
	float mDamage;
	float mAreaOfEffect;
	float mFlightTime;
};

struct UnitData;
class EntityProjectileSystem
{
public:
	static void Init();
	static void Clear();

	static int NewProjectile(Entity* owner, Vec2f pos, Vec2f facing, const UnitData& data);
	static void RemoveProjectile(int id);
	static EntityProjectile* GetProjectile(int id);

	static JobHandle Update(JobHandle dependency);

private:
	static void UpdateProjectileChunk(int chunk);
};

} // namespace Tmpl